package com.itboy.mall.pms.product.web;

import com.itboy.mall.pms.product.vo.SkuItemVo;
import com.itboy.mall.pms.skuinfo.service.IMallSkuInfoService;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

@Validated
@Api(value = "详情", tags = {"详情管理"})
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@Controller
@RequestMapping("/search/item")
public class ItemController {

	private final IMallSkuInfoService iMallSkuInfoService;


	@SneakyThrows
	@GetMapping(value = {"/{skuId}.html"})
	public String indexPage(Model model, @PathVariable Long skuId){
		SkuItemVo skuItemVo=iMallSkuInfoService.itemBySkuId(skuId);
		model.addAttribute("item",skuItemVo);
		return  "item";
	}
}
